package model.config
{
	import flash.utils.describeType;
	import flash.utils.getDefinitionByName;
	
	import ricky.utils.Utils;
	
	/**
	 * 单位基本配置
	 */
	public dynamic class Unit extends Object
	{
		public function Unit()
		{
			super();
		}
		
		public function get scale():Number
		{
			return _scale;
		}

		public function set scale(value:Number):void
		{
			_scale = value;
		}

		public function get speed():int
		{
			return _speed;
		}

		public function set speed(value:int):void
		{
			_speed = value;
		}

		/**
		 * 单位id
		 */
		public function get unitID():String
		{
			return _unitID;
		}
		
		/**
		 * @private
		 */
		public function set unitID(value:String):void
		{
			_unitID = value;
		}
		
		/**
		 * 单位名称
		 */
		public function get name():String
		{
			return _name;
		}
		
		/**
		 * @private
		 */
		public function set name(value:String):void
		{
			_name = value;
		}
		
		/**
		 * 单位ico
		 */
		public function get uicon():String
		{
			return _uicon;
		}
		
		/**
		 * @private
		 */
		public function set uicon(value:String):void
		{
			_uicon = value;
		}
		
		/**
		 * 单位模型
		 */
		public function get model():String
		{
			return _model;
		}
		
		/**
		 * @private
		 */
		public function set model(value:String):void
		{
			_model = value;
		}
		
		/**
		 * 是否建筑物
		 */
		public function get isBuilding():Boolean
		{
			return _isBuilding;
		}
		
		/**
		 * @private
		 */
		public function set isBuilding(value:Boolean):void
		{
			_isBuilding = value;
		}
		
		/**
		 * 单位描述
		 */
		public function get tips():String
		{
			return _tips;
		}
		
		/**
		 * @private
		 */
		public function set tips(value:String):void
		{
			_tips = value;
		}
		
		/**
		 * 动画属性 动画播放动作
		 */
		public function get act():String
		{
			return _act;
		}
		
		/**
		 * @private
		 */
		public function set act(value:String):void
		{
			_act = value;
		}
		
		
		/**
		 * 超级提示
		 */
		public function get revivetip():String
		{
			return _revivetip;
		}
		
		/**
		 * @private
		 */
		public function set revivetip(value:String):void
		{
			_revivetip = value;
		}
		
		/**
		 * 单位技能
		 */
		public function get ability():String
		{
			return _ability;
		}
		
		public function set ability(value:String):void
		{
			_ability = value;
		}
		
		/**
		 * 建筑技能
		 */
		public function get buildAbility():String
		{
			return _buildAbility;
		}
		
		/**
		 * @private
		 */
		public function set buildAbility(value:String):void
		{
			_buildAbility = value;
		}
		
		/**
		 * 
		 * 感知
		 */
		public function get perception():String
		{
			return _perception;
		}
		
		/**
		 * 感知
		 */
		public function set perception(value:String):void
		{
			_perception = value;
		}
		
		public function get drop():String
		{
			return _drop;
		}
		
		/**
		 * 可视范围
		 */
		public function get rangeVisible():int
		{
			return _rangeVisible;
		}
		
		/**
		 * @private
		 */
		public function set rangeVisible(value:int):void
		{
			_rangeVisible = value;
		}
		
		/**
		 * 掉落
		 */
		public function set drop(value:String):void
		{
			_drop = value;
		}
		
		/**
		 * 克隆对象
		 */
		public function clone():Unit
		{
			var u:Unit=new Unit();
			for(var s:String in this)
			{
				u[s]=this[s];	
			}
			
			u._ability=this.ability;
			u._act=this.act;
			u._buildAbility=this._buildAbility;
			u._drop=this._drop;
			u._isBuilding=this.isBuilding;
			u._model=this.model;
			u._name=this.name;
			u._perception=this.perception;
			u._rangeVisible=this.rangeVisible;
			u._revivetip=this.revivetip;
			u._scale=this.scale;
			u._speed=this.speed;
			u._tips=this.tips;
			u.uicon=this.uicon;
			u.unitID=this.unitID;
			
			
			return u;
		}
		
		public function copy(obj:Object):void
		{
			var dis:XMLList=describeType(this).accessor;
			var accessor:*;//访问器
			var t:String;//类型
			var c:*;
			for(var s:String in obj)
			{
				c=obj[s];
				if(dis)
				{
					accessor=dis.(@name==s);
					if(accessor)
					{
						t=accessor.@type;//类型
						if(t=="*")
							t="Object";
						else if(t=="")
							this[s]=c;
						else
							this[s]=flash.utils.getDefinitionByName(t)(c);
					}else
						this[s]=obj[s];
				}else
					this[s]=obj[s];
			}
			
		}
		
		//************************ private ************************
		
		private var _unitID:String;//单位id
		private var _name:String;//单位名称
		private var _speed:int;
		
		private var _uicon:String;//单位icos
		private var _model:String;//单位模型
		private var _act:String;//动画属性
		private var _rangeVisible:int;//可视范围
		
		private var _ability:String;//技能
		private var _buildAbility:String;//建筑技能
		private var _isBuilding:Boolean;//是否是建筑
		private var _tips:String;//说明
		private var _revivetip:String;//超级提示
		private var _scale:Number=1;//放大
		
		private var _perception:String;//感知
		private var _drop:String;//掉落
	}
}